package com.itheima.d7_stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest1 {
    public static void main(String[] args) {
        List<String> names =new ArrayList<>();
        Collections.addAll(names,"张三","李四","王五");
        System.out.println(names);

        List<String> list =new ArrayList<>();
        for (String name : names) {
            if(name.startsWith("张")&&name.length()==2){
                list.add(name);
            }
        }
        System.out.println(list);


        List<String> list2 =names.stream().filter(name->name.startsWith("张")&&name.length()==2).collect(Collectors.toList());
        System.out.println(list2);

    }


}
